package design.mode.effective_java.chapter4.item17;

/**
 * 用静态方法代替构造方法创建不可变类
 *
 * @author ZhongMingde on 2021/8/14
 */

public class Complex2 {
    private final double re;
    private final double im;

    private Complex2(double re, double im) {
        this.re = re;
        this.im = im;
    }

    public static Complex2 valueOf(double re,double im){
        return new Complex2(re, im);
    }

}
